/*
  Copyright (c) 2015,2017 Qualcomm Technologies, Inc.
  All Rights Reserved.
  Confidential and Proprietary - Qualcomm Technologies, Inc.
*/

/* Example asynchronous FastCV-based image processing operation queue - test application */

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <semaphore.h>
#include <assert.h>
#include <unistd.h>
#include <time.h>

#include "utils.hpp"

#include <vector>

extern void test_cpu_main(int x, int y, int w, int h, int patch_size, const char *in_path, const char *out_path);
extern void test_dsp_main(int x, int y, int w, int h, int patch_size, const char *in_path, const char *out_path);



static void print_usage()
{
    printf( "Usage:\n"
            "    tracker_kcf [-d domain] [-U unsigned_PD] [-t loops] [-s patch_siz]\n\n"
            "Options:\n"
            "-d domain: DSP domain to run. This example is supported only on CDSP.\n"
            "    3: run the example on CDSP\n"
            "        Default Value: 3(CDSP) for targets having CDSP.\n"
            "-U unsigned_PD: Run on signed or unsigned PD.\n"
            "    0: run on signed PD.\n"
            "    1: run on unsigned PD.\n"
            "        Default Value: 1\n"
            "-t loops: Number of FastRPC calls to each DSP routine.\n"
            "        Default Value: 1\n"
            "-s patch_size: kcf patch size.\n"
            "        Default Value: 128\n"
            );
}


int main(int argc, char* argv[]) {

    int nErr = 0;
    int option = 0;
    int domain_id = -1;
    int loops = 1;
    int unsignedpd_flag = 1;
    bool is_unsignedpd_enabled = false;
    int patch_size = 128;
    while ( (option = getopt(argc, argv,"d:t:U:s:")) != -1 ) {
        switch (option) {
            case 'd' : domain_id = atoi(optarg);
                break;
            case 't' : loops = atoi(optarg);
                break;
            case 'U' : unsignedpd_flag = atoi(optarg);
                break;
            case 's' : patch_size = atoi(optarg);
                break;
            default:
                print_usage();
                return -1;
        }
    }
    // Rect ROI(520, 470, 128, 128);
    int x = 520; 
    int y = 470;
    int w = 128;
    int h = 128;
    printf("---------------test cpu-----------------\n");
    // test_cpu_main(x, y, w, h, patch_size, "/vendor/kcf/in", "/vendor/kcf/cpu_out");

    printf("---------------test dsp-----++------------\n");
    test_dsp_main(x, y, w, h, patch_size, "/vendor/kcf/in", "/vendor/kcf/dsp_out");

    printf("\nDone\n");
bail:
    return nErr;
}
